package com.ruoyi.process.pipemaintainence2.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.process.dynamic.service.BpmnDynamicService;
import com.ruoyi.process.pipemaintainence.service.BpmnCopyProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.process.pipemaintainence2.mapper.TBpmnCopyProcessMapper;
import com.ruoyi.process.pipemaintainence2.domain.TBpmnCopyProcess;
import com.ruoyi.process.pipemaintainence2.service.ITBpmnCopyProcessService;
import com.ruoyi.common.core.text.Convert;

/**
 * 抄送流程Service业务层处理
 *
 * @author Xianlu Tech
 * @date 2019-12-05
 */
@Service
public class TBpmnCopyProcessServiceImpl implements ITBpmnCopyProcessService {

    @Autowired
    private TBpmnCopyProcessMapper tBpmnCopyProcessMapper;

    @Autowired
    protected BpmnCopyProcessService processService;

    /**
     * 查询抄送流程
     *
     * @param id 抄送流程ID
     * @return 抄送流程
     */
    @Override
    public TBpmnCopyProcess selectTBpmnCopyProcessById(String id) {
        return tBpmnCopyProcessMapper.selectTBpmnCopyProcessById(id);
    }

    /**
     * 查询抄送流程列表
     *
     * @param tBpmnCopyProcess 抄送流程
     * @return 抄送流程
     */
    @Override
    public List<TBpmnCopyProcess> selectTBpmnCopyProcessList(TBpmnCopyProcess tBpmnCopyProcess) {
        return tBpmnCopyProcessMapper.selectTBpmnCopyProcessList(tBpmnCopyProcess);
    }

    /**
     * 新增抄送流程
     *
     * @param tBpmnCopyProcess 抄送流程
     * @return 结果
     */
    @Override
    public int insertTBpmnCopyProcess(TBpmnCopyProcess tBpmnCopyProcess) {
        tBpmnCopyProcess.setCreateTime(DateUtils.getNowDate());
        return tBpmnCopyProcessMapper.insertTBpmnCopyProcess(tBpmnCopyProcess);
    }

    /**
     * 修改抄送流程
     *
     * @param tBpmnCopyProcess 抄送流程
     * @return 结果
     */
    @Override
    public int updateTBpmnCopyProcess(TBpmnCopyProcess tBpmnCopyProcess) {
        tBpmnCopyProcess.setUpdateTime(DateUtils.getNowDate());
        return tBpmnCopyProcessMapper.updateTBpmnCopyProcess(tBpmnCopyProcess);
    }

    /**
     * 删除抄送流程对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTBpmnCopyProcessByIds(String ids) {
        return tBpmnCopyProcessMapper.deleteTBpmnCopyProcessByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除抄送流程信息
     *
     * @param id 抄送流程ID
     * @return 结果
     */
    @Override
    public int deleteTBpmnCopyProcessById(String id) {
        return tBpmnCopyProcessMapper.deleteTBpmnCopyProcessById(id);
    }

    /**
     * 抄送给我的流程
     *
     * @return
     */
    @Override
    public List<Map<String, Object>> copyToMe() {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        String userId = ShiroUtils.getSysUser().getUserId().toString();
        List<Map<String, Object>> result = processService.findCopyProcessByUserId(pageNum, pageSize, userId);
        return result;
    }
}
